package rlb;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import rlb.test.RobotTestBed;

/**
 * FlankBot Accuracy Test.
 * @author Remy Baumgarten
 *
 */
public class TestFlankBotAccuracy extends RobotTestBed {

  @Override
  public String getRobotNames() {
    return "sample.Walls,rlb.FlankBot";
  }

  /**
   * This test runs for 10 rounds.
   * 
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * The actual test, which asserts that FlankBot has Accuracy.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {

    // Return the results in order of getRobotNames.
    BattleResults[] results = event.getIndexedResults();
    int otherBotDamage = results[0].getBulletDamage();
    System.out.println("Bullet Hit Count: " + otherBotDamage);
    // Sanity check that results[1] is FlankBot (not strictly necessary, but illustrative).
    assertEquals("Check results[1]", results[1].getTeamLeaderName(), "rlb.FlankBot");

    // Check to see if FlankBot can Hit Walls a few times
    assertTrue("Checking to see if we can hit target", (otherBotDamage > 20));
  }
}